<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <title><? echo $title ?></title>
<? require("lib.php"); ?>
</head>
<body>
<div class="content-box"><!-- Start Content Box -->
  <div class="content-box-header">
      <h3><? echo $title ?></h3>
      <div class="clear"></div>
  </div> <!-- End .content-box-header -->
  <div class="content-box-content">
<?
switch ($do) {
	case "flip":
	flip($id);
	break;
	case "add":
	add();
	break;
	case "delete":
	delete($id);
	break;
	default:
	show_info($info);
}
 ?>
<? function show_box($row, $iseditmode, $isadd){
	global $id, $baseurl, $url, $title, $h, $cate, $lang, $option, $arrlang;
?>
	<table width="99%" cellspacing="0" cellpadding="3" class="mbox">
      <tr class="th"><td class="thtitle" width="25%" align="right"><? echo $title ?></td><td><input value="<?php echo decode($row["id"]) ?>" name="id" type="hidden"></td></tr>
      <tr><td class="l"><?=ROOT_TABLE?></td><td><input value="<?php echo decode($row["table_name"]) ?>" name="table_name" type="text" class="g"></td></tr>
      <tr><td class="l"><?=ROOT_FIELD?></td><td><input value="<?php echo decode($row["field_name"]) ?>" name="field_name" type="text" class="g"></td></tr>
      <tr><td class="l">&nbsp;</td><td><br><input <? if(!$iseditmode)echo "class='hide'";?> type="submit" value="&nbsp; <?=ROOT_SAVE?> &nbsp;">&nbsp;&nbsp;<a onClick="history.go(-1)">[ <?=ROOT_CANCEL?> ]</a><br><br></td></tr>
    </table>
    <? } ?>
	<? function show_boxes($result){
		global $url, $page, $pages, $cateid, $cate, $s, $lang, $arrcurrency;
    		$str='<table width="99%" cellspacing="0" class="mlist"><tr class="th"><td><strong>#</strong></td><td><strong>'.ROOT_TABLE.'</strong></td><td><strong>'.ROOT_FIELD.'</strong></td><td><a href="'.$url.'.php?do=add">[ '.ROOT_ADD.' ]</a></td></tr>';
		$count=1;
    foreach( $result as $row)
		{
			$uid=decode($row['id']);
			$enable=$row['is_enabled']?ROOT_DISABLE:ROOT_ENABLE;
			$str.="<tr ".(($row['is_enabled'])?"":"class=\"disabled\"")."><td>".$uid.".</td><td>".decode($row['table_name'])."</td><td>".decode($row['field_name'])."</td><td>";
			//if($row['optional']) {
				$str.="<a href=\"$url.php?do=flip&cateid=$cateid&page=$page&id=".decode($row['id'])."\">".$enable."</a> | <a href=\"$url.php?cateid=$cateid&page=$page&do=delete&id=".decode($row['id'])."\" onClick=\"return delc();\">".ROOT_DELETE."</a>";
			//}
			//else {
			//	$str.=ROOT_DISABLE;
			//}
			$str.="</td></tr>";
			$count++;
		}
		$str.= "</table>";
		echo $str;
		if($count==1) echo "<br>".ROOT_NO_DATA."!";
		echo echo_page($page, $pages, $url.'-'.$cateid.'-p');
         } ?>
     <br class="clear" />
		</div> <!-- End .content-box-content -->
    <br class="clear" />
	</div><!-- End .content-box -->
</body>
</html>